﻿using System;
using System.Net;

namespace SCG.SolarVengeanceEngine.StarShips
{
    //NukeMissiles
    public class NukeMissile : Missile
    {
        //constructor
        public NukeMissile(SVGame game, Player owner, int engines, int warheads, StarSystem origin)
            : base(game, owner, engines, warheads, origin)
        {
        }

        //Name
        public override string Name
        {
            get
            {
                return "NukeMissile";
            }
        }

        //description
        public override string Description
        {
            get
            {
                return "Once a NukeMissile targets a StarSystem its orders cannot be changed.  NukeMissiles contain a Warheads, and each Warhead reduces a StarSystem's Resources by up to 25%.  If the target StarSystem already has low Resources, its Resources can be reduced to below zero.  NukeMissiles are immune to StarTillery fire.";
            }
        }

        //ship type
        public override StarShipType ShipType
        {
            get
            {
                return StarShipType.NukeMissile;
            }
        }

        //Impact reduces resources
        protected override void TargetAdjacentStarSystem(StarSystem system)
        {
            for (int w = 0; w < Value; w++)
            {
                int maxDamage = system.ResourcesInt / 4;
                if (maxDamage < 5)
                    maxDamage = 5;
                system.Resources -= (SVGame.RNG.Next(maxDamage) + 1);
            }
            Game.SubmitStateChange(StateChange.SetResources, system, system.Resources);

            //and destroys the missile
            Game.DestroyStarShip(this);
        }
    }
}
